package com.zl.controller;

import com.zl.domain.User;
import com.zl.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * com.zl.controller
 *
 * @author liyawei
 * @date 2018/4/8/008 16:09
 */
@Controller
public class IndexController {

    @Autowired
    UserService userService;

    @RequestMapping("/index")
    public ModelAndView index(){
        ModelAndView mv = new ModelAndView();

        try {
            User user = userService.getByName("小豆子");
            mv.addObject("user",user);
            mv.setViewName("login");
        } catch (Exception e) {
            e.printStackTrace();
        }

        return mv;
    }
}
